{% load i18n l10n sekizai_tags static cms_tags cms_js_tags cms_static %}

{% addtoblock "css" %}<link rel="stylesheet" href="{% static_with_version "cms/css/cms.base.css" %}" />{% endaddtoblock %}
{% for css in cms_toolbar.media.render_css %}
    {% addtoblock "css" %}{{ css }}{% endaddtoblock %}
{% endfor %}

{% addtoblock "js" %}
<script data-cms src="{% static_with_version "cms/js/dist/bundle.toolbar.min.js" %}" type="text/javascript"></script>
<script data-cms-config id="cms-config-json" type="application/json">
{
    "mode": {% if cms_toolbar.edit_mode_active or cms_toolbar.structure_mode_active %}"draft"{% else %}"live"{% endif %},
    "auth": {% if user.is_authenticated %}true{% else %}false{% endif %},
    "debug": {% if debug %}true{% else %}false{% endif %},
    "csrf": "{{ csrf_token }}",
    "request": {
        "language": "{{ cms_toolbar.request_language }}",
        "model": "{{ cms_toolbar.get_object_model }}",
        "page_id": "{{ request.current_page.pk|unlocalize }}",
        "pk": "{{ cms_toolbar.get_object_pk|unlocalize }}",
        "toolbar": "{% language cms_toolbar.request_language %}{% cms_admin_url "cms_usersettings_get_toolbar" %}{% endlanguage %}"
    },
    "lang": {
        {% if debug and user.is_authenticated %}
        "debug": "{% filter escapejs %}{% blocktrans %}Development version using django CMS {{ cms_version }}, Django {{ django_version }}, Python {{ python_version }}{% endblocktrans %}{% endfilter %}",
        {% endif %}
        "cancel": "{% filter escapejs %}{% trans "Cancel" %}{% endfilter %}",
        "error": "<strong>{% filter escapejs %}{% trans "The following error occurred:" %}{% endfilter %}</strong> ",
        "success": "{% filter escapejs %}{% trans "Action successful." %}{% endfilter %}",
        "confirm": "{% filter escapejs %}{% trans "Are you sure you want to delete this plugin?" %}{% endfilter %}",
        "publish": "{% filter escapejs %}{% trans "Are you sure you want to publish this page?" %}{% endfilter %}",
        "addPluginPlaceholder": "{% filter escapejs %}{% trans "Plugin will be added here" %}{% endfilter %}",
        "confirmDirty": "{% filter escapejs %}{% trans "You have unsaved changes." %}{% endfilter %}",
        "loading": "{% filter escapejs %}{% trans "Loading" %}{% endfilter %}",
        "confirmDirtyESC": "{% filter escapejs %}{% trans "Are you sure you want to abandon these changes?" %}{% endfilter %}",
        "errorLoadingEditForm": "{% filter escapejs %}{% trans "The form could not be loaded. Please check that the server is running correctly." %}{% endfilter %}",
        "mostUsed": "{% filter escapejs %}{% trans "Most used" %}{% endfilter %}",
        "shortcuts": "{% filter escapejs %}{% trans "Shortcuts" %}{% endfilter %}",
        "unhandledPageChange": "{% filter escapejs %}{% trans "The page was changed in the meantime, reloading..." %}{% endfilter %}",
        "shortcutAreas": [
            {
                "title": "{%  trans "CMS-wide Shortcuts" %}",
                "shortcuts": {
                    "help": {
                        "shortcut": "?",
                        "desc": "{% filter escapejs %}{% trans "Bring up this help dialog" %}{% endfilter %}"
                    },
                    "esc": {
                        "shortcut": "ESC",
                        "desc": "{% filter escapejs %}{% trans "Close/cancel" %}{% endfilter %}"
                    },
                    "toggle-structure-board": {
                        "shortcut": "space",
                        "desc": "{% filter escapejs %}{% trans "Toggle structure mode" %}{% endfilter %}"
                    },
                    "toggle-structure-board-using-hovered-plugin": {
                        "shortcut": "shift+space",
                        "desc": "{% filter escapejs %}{% trans "Toggle structure mode and highlight hovered-over plugin" %}{% endfilter %}"
                    },
                    "create-dialog": {
                        "shortcut": "alt+c",
                        "desc": "{% filter escapejs %}{% trans "Open \"Create\" dialog" %}{% endfilter %}"
                    },
                    "toolbar": {
                        "shortcut": "f > t / alt+t",
                        "desc": "{% filter escapejs %}{% trans "Focus on Toolbar" %}{% endfilter %}"
                    }
                }
            },
            {
                "title": "Structureboard",
                "shortcuts": {
                    "placeholders": {
                        "shortcut": "f > p / alt+p",
                        "desc": "{% filter escapejs %}{% trans "Focus on placeholders" %}{% endfilter %}"
                    },
                    "traversing": {
                        "shortcut": "tab / shift+tab",
                        "desc": "{% filter escapejs %}{% trans "Move to next/previous element" %}{% endfilter %}"
                    },
                    "enter": {
                        "shortcut": "enter",
                        "desc": "{% filter escapejs %}{% trans "Focus on plugins of placeholder" %}{% endfilter %}"
                    },
                    "edit": {
                        "shortcut": "e",
                        "desc": "{% filter escapejs %}{% trans "Edit plugin" %}{% endfilter %}"
                    },
                    "add": {
                        "shortcut": "+ / a",
                        "desc": "{% filter escapejs %}{% trans "Add plugin" %}{% endfilter %}"
                    },
                    "settings": {
                        "shortcut": "! / s",
                        "desc": "{% filter escapejs %}{% trans "Open actions menu" %}{% endfilter %}"
                    },
                    "collapse": {
                        "shortcut": "x",
                        "desc": "{% filter escapejs %}{% trans "Expand/collapse" %}{% endfilter %}"
                    }
                }
            }
        ]
    },
    "urls": {
        "settings": "{% cms_admin_url "cms_usersettings_session_store" %}",
        "static": "{{ STATIC_URL }}"
    },
    "settings": {
        "version": "{{ cms_version }}",
        "toolbar": "expanded",
        "mode": {% if cms_toolbar.structure_mode_active %}"structure"{% else %}"edit"{% endif %},
        "sideframe": { "url": "" },
        "sideframe_enabled": {{ cms_toolbar.sideframe_enabled|yesno:"true,false" }},
        "states": [],
        "edit": "{{ cms_edit_url }}",
        "edit_off": "{{ cms_preview_url }}",
        "structure": "{{ cms_structure_url }}",
        "legacy_mode": {{ cms_toolbar.uses_legacy_structure_mode|yesno:"true,false" }}
    },
    "clipboard": {
        "id": "{{ cms_toolbar.clipboard.pk|unlocalize }}",
        "url": "{% if cms_toolbar.clipboard.pk %}{% cms_admin_url "cms_placeholder_clear_placeholder" cms_toolbar.clipboard.pk %}{% endif %}"
    },
    "messages": "{% filter escapejs %}{% if messages %}{% for message in messages %}{{ message }}{% endfor %}{% endif %}{% endfilter %}",
    "error": "{% filter escapejs %}{% if cms_toolbar.login_form.errors or cms_toolbar_login_error %}{% blocktrans %}<strong>Login failed.</strong> Please check your credentials and try again.{% endblocktrans %}{% endif %}{% endfilter %}"
}
</script>
{% endaddtoblock %}
{% if cms_toolbar.clipboard_plugin %}{% render_plugin_init_js cms_toolbar.clipboard_plugin %}{% endif %}
{% for js in cms_toolbar.media.render_js %}
    {% addtoblock "js" %}{{ js }}{% endaddtoblock %}
{% endfor %}
